
package com.jf.cloud.multishop.controller.platform;

import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.common.security.AuthUserContext;
import com.jf.cloud.multishop.dto.ShopWithdrawCashConfigDto;
import com.jf.cloud.multishop.dto.ShopWithdrawCashDTO;
import com.jf.cloud.multishop.service.ShopWithdrawCashService;
import com.jf.cloud.multishop.vo.ShopWithdrawCashVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zz
 * @Date 2021/6/11 9:28
 */
@RestController("platformShopWithdrawCashController")
@RequestMapping("/p/shop_withdraw_cash")
@Tag(name = "platform-商家提现申请信息")
public class ShopWithdrawCashController {

    @Autowired
    private ShopWithdrawCashService shopWithdrawCashService;

    @GetMapping("/info")
    @Operation(summary = "根据提现记录id查看提现记录" , description = "根据提现记录id查看提现记录")
    public ServerResponseEntity<ShopWithdrawCashVO> getById(@RequestParam(value = "cashId") Long cashId) {
        ShopWithdrawCashVO shopWithdrawCashVO = shopWithdrawCashService.getDetailByCashId(cashId);
        return ServerResponseEntity.success(shopWithdrawCashVO);
    }

    @PutMapping("/audit")
    @Operation(summary = "审核商家提现信息" , description = "审核商家提现信息")
    public ServerResponseEntity<Void> audit(@RequestBody ShopWithdrawCashDTO shopWithdrawCashDTO) {
        shopWithdrawCashService.auditWithdrawCash(shopWithdrawCashDTO, AuthUserContext.get().getUserId());
        return ServerResponseEntity.success();
    }

    @PostMapping("/save")
    @Operation(summary = "设置提现金额" , description = "设置提现金额")
    public ServerResponseEntity<Void> saveWithdrawCashConfig(@RequestBody ShopWithdrawCashConfigDto shopWithdrawCashDto) {
        System.out.println(shopWithdrawCashDto.getWithdrawCashLeast());
        System.out.println(shopWithdrawCashDto.getWithdrawCashMax());
        shopWithdrawCashService.saveConfig(shopWithdrawCashDto);
        return ServerResponseEntity.success();
    }
    @GetMapping("/getWithdrawCash")
    public ServerResponseEntity<ShopWithdrawCashConfigDto> getWithdrawCashConfig(){
        return ServerResponseEntity.success(shopWithdrawCashService.getConfig());
    }
}
